#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QSerializer>


class TestCustomObject: public QSerializer
{
    Q_GADGET
    QS_SERIALIZABLE
public:
    QS_FIELD(int, code)
    QS_FIELD(QString, msg)
};


class TestJsonData: public QSerializer
{
    Q_GADGET
    QS_SERIALIZABLE
public:
    TestJsonData(){}
    TestJsonData( const int& t_digit, const QString& t_string, \
               const bool & t_flag, const double& t_d_digit,  \
               const QStringList& t_list, const TestCustomObject& t_object) {
        digit = t_digit;
        string = t_string;
        flag = t_flag;
        d_digit = t_d_digit;
        list = t_list;
        object = t_object;
    }

    QS_FIELD(int, digit)                // 测试整形
    QS_FIELD(QString, string)           // 测试字符串
    QS_FIELD(bool, flag)                // 测试bool
    QS_FIELD(double, d_digit)           // 测试double
    QS_COLLECTION(QList, QString, list) // 测试列表
    QS_OBJECT(TestCustomObject, object) // 测试自定义对象
};

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

    void structToJson();

    void jsonToStruct();



private:
    Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
